package tx_chat

import (
	"longmen/server/internal/rpc/tencentim/subscribe"
	"sync"

	"go.uber.org/zap"
)

// TxChatHistoryEs 匿名登录消息
type TxChatHistoryEs struct {
	logger *zap.SugaredLogger
	tx     *subscribe.TxChat
}

var txChatHistory *TxChatHistoryEs
var txche sync.Once

func NewChatHistoryEs(log *zap.SugaredLogger) *TxChatHistoryEs {
	txche.Do(func() {
		txChatHistory = &TxChatHistoryEs{
			logger: log,
			tx:     subscribe.NewTxChat(log),
		}
	})
	return txChatHistory
}

func (t *TxChatHistoryEs) Process(data []byte) bool {
	return t.tx.ChatHistoryToEs(data)
}
